package com.zero.xiaodai.constant;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;


/**
 * 
 * @author hulibin
 *
 * @createTime 创建时间：2017年11月29日 上午10:04:47
 * 接口返回的对象
 */
public class ResultType implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 8524835075858984975L;

	/** 返回状态码,使用系统定义的常量 */
	private int status;

	/** 提示信息 */
	private String msg;

	/** 返回数据集，可以是各种类型 */
	private Object data;
	
	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public ResultType() {
	}

	public ResultType(int status, String msg, int dataNum, Object data) {
		this.status = status;
		this.msg = msg;
		this.data = data;
	}

	public ResultType(int status, String msg) {
		this.status = status;
		this.msg = msg;
		this.data = null;
	}
	
	

	public ResultType(int status, String msg, Object data) {
		super();
		this.status = status;
		this.msg = msg;
		this.data = data;
	}

	@Override
	public String toString() {
		return "ResultType [status=" + status + ", msg=" + msg + ", data=" + data + "]";
	}

	/** */
	public static ResultType getError(String msg) {
		return new ResultType(SysStatus.ERROR.getStatus(), msg);
	}

	/** 操作成功 */
	public static ResultType getSuccess() {
		return new ResultType(SysStatus.SUCCESS.getStatus(),SysStatus.SUCCESS.getMsg());
	}
	
	public static ResultType getSuccess(String msg) {
		return new ResultType(SysStatus.SUCCESS.getStatus(),msg);
	}
	public static ResultType getSuccess(Object data) {
		return new ResultType(SysStatus.SUCCESS.getStatus(), SysStatus.SUCCESS.getMsg(), 1, data);
	}
	public static ResultType getSuccess(int num, Object data) {
		return new ResultType(SysStatus.SUCCESS.getStatus(), SysStatus.SUCCESS.getMsg(), num, data);
	}
	
	public static ResultType getSuccess(String msg,int num, Object data) {
		return new ResultType(SysStatus.SUCCESS.getStatus(), msg, num, data);
	}
	
	public static ResultType getNoDataSuccess(String msg) {
		return new ResultType(SysStatus.SUCCESS.getStatus(), msg);
	}
	
	public static ResultType getSuccess(String msg, Object data) {
		return new ResultType(SysStatus.SUCCESS.getStatus(), msg, data);
	}
	/** 系统异常 */
	public static ResultType getException() {
		return new ResultType(SysStatus.EXCEPTION.getStatus(),SysStatus.EXCEPTION.getMsg());
	}
	
	public static ResultType getException(String msg) {
		return new ResultType(SysStatus.EXCEPTION.getStatus(),msg);
	}

	/** 操作失败 */
	public static ResultType getFail() {
		return new ResultType(SysStatus.FAIL.getStatus(),SysStatus.FAIL.getMsg());
	}

	public static ResultType getFail(String msg) {
		return new ResultType(SysStatus.FAIL.getStatus(), msg);
	}

	/** 权限不足 */
	public static ResultType getNoAuth(){
		return new ResultType(SysStatus.NO_AUTH.getStatus(), SysStatus.NO_AUTH.getMsg());
	}
	
	public static ResultType getNoAuth(String msg){
		return new ResultType(SysStatus.NO_AUTH.getStatus(), msg);
	}
	
	/** 参数不合法 */
	public static ResultType getParamIllegal(){
		return new ResultType(SysStatus.PARAM_ILLEGAL.getStatus(), SysStatus.PARAM_ILLEGAL.getMsg());
	}
	
	public static ResultType getParamIllegal(String msg){
		return new ResultType(SysStatus.PARAM_ILLEGAL.getStatus(), msg);
	}

	public static ResultType getChatName(String chatName) {
		Map<String, String> map = new HashMap<>(2);
		map.put("chatName", chatName);
		return new ResultType(SysStatus.SUCCESS.getStatus(), "会话名称", 0, map);
	}

	/** 未查询到数据 */
	public static ResultType getNoData() {
		return new ResultType(SysStatus.NO_DATA.getStatus(),SysStatus.NO_DATA.getMsg());
	}


}
